package com.zstu.mall.dao;

import com.zstu.mall.common.BaseRepository;
import com.zstu.mall.entity.Order;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import javax.transaction.Transactional;
import java.util.List;

/**
 * @author     : wuyc
 * @description: OrderDao
 * @date       : Created in 2019/11/24
 */
public interface OrderDao extends BaseRepository<Order, String> {

    /**
     * 更改订单状态
     * @param status
     * @param id
     */
    @Modifying
    @Transactional
    @Query(value = "update `order` o set o.status=?1 where o.id=?2",nativeQuery = true)
    void updateStatus(String status,String id);

    /**
     * 查找用户的订单
     * @param userId
     * @return
     */
    List<Order> findByUserId(String userId);

}
